| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Matrix.h
1 // Matrix.h
3 //
5
6 namespace nkMaths
7 {
14 class Matrix
15 {
16 public :
17
22 Matrix () noexcept ;
34 Matrix (float m00, float m01, float m10, float m11) noexcept ;
51 Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) noexcept ;
74 Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) noexcept ;
80 Matrix (const Matrix& other) noexcept ;
81
82 // Getters
86 Vector getRow0 () const ;
90 Vector getRow1 () const ;
94 Vector getRow2 () const ;
98 Vector getRow3 () const ;
102 Vector getCol0 () const ;
106 Vector getCol1 () const ;
110 Vector getCol2 () const ;
114 Vector getCol3 () const ;
123 float get (unsigned int row, unsigned int col) const ;
124
125 // Setters
135 Matrix& set (float val, unsigned int row, unsigned int col) ;
136
137 // Alterations
141 Matrix getInverseMat2 () const ;
145 Matrix getInverseMat3 () const ;
149 Matrix getInverseMat4 () const ;
153 Matrix getTranspose () const ;
159 Matrix& inverseMat2 () ;
165 Matrix& inverseMat3 () ;
171 Matrix& inverseMat4 () ;
177 Matrix& transpose () ;
178
179 // Transformations
185 Vector getPositionComponent () const ;
191 Matrix getOrientationComponent () const ;
197 Vector getScaleComponent () const ;
205 void getDecomposed (Vector& position, Matrix& orientation, Vector& scale) const ;
206
215 Matrix& setToViewMatrixDirection (const Vector& position, const Vector& direction, const Vector& upDirection) ;
228 Matrix& setToPerspectiveMatrix (float fov, float aspect, float near, float far) ;
243 Matrix& setToPerspectiveReverseZMatrix (float fov, float aspect, float near, float far = -1.f) ;
260 Matrix& setToOffCenterPerspectiveMatrix (float fovLeft, float fovRight, float fovTop, float fovBottom, float near, float far) ;
278 Matrix& setToOffCenterPerspectiveReverseZMatrix (float fovLeft, float fovRight, float fovTop, float fovBottom, float near, float far = -1.f) ;
291 Matrix& setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float near, float far) ;
305 Matrix& setToOrthographicReverseZMatrix (float widthNearPlane, float heightNearPlane, float near, float far) ;
312 Matrix& setPositionComponent (const Vector& position) ;
319 Matrix& setOrientationComponent (const Quaternion& rot) ;
326 Matrix& setScaleComponent (const Vector& scale) ;
335 Matrix& setToTransformation (const Vector& position, const Quaternion& orientation, const Vector& scale) ;
336
337 // Utilities
341 float getDeterminantMat2 () const ;
345 float getDeterminantMat3 () const ;
349 float getDeterminantMat4 () const ;
353 float getTraceMat2 () const ;
357 float getTraceMat3 () const ;
361 float getTraceMat4 () const ;
362
366 nkMemory::String toString () const ;
374 Matrix& fromString (nkMemory::StringView str) ;
375
376 // Operators
383 Matrix& operator= (const Matrix& other) noexcept ;
390 bool operator== (const Matrix& other) ;
397 bool operator!= (const Matrix& other) ;
404 Matrix operator+ (const Matrix& other) const ;
410 void operator+= (const Matrix& other) ;
417 Matrix operator- (const Matrix& other) const ;
423 void operator-= (const Matrix& other) ;
430 Matrix operator* (const Matrix& other) const ;
437 Vector operator* (const Vector& vec) const ;
446 Quaternion operator* (const Quaternion& q) const ;
453 Matrix operator* (float scalar) const ;
459 void operator*= (const Matrix& other) ;
465 void operator*= (float scalar) ;
472 Matrix operator/ (float scalar) const ;
478 void operator/= (float scalar) ;
479
480 public :
481
482 // Attributes
483 float _m [4][4] ;
484 } ;
485 }
nkMaths::Matrix::getTraceMat4
float getTraceMat4() const
nkMaths::Matrix::fromString
Matrix & fromString(nkMemory::StringView str)
nkMaths::Matrix::toString
nkMemory::String toString() const
nkMaths::Matrix::getTraceMat2
float getTraceMat2() const
nkMaths::Matrix::getInverseMat3
Matrix getInverseMat3() const
nkMaths::Matrix::inverseMat4
Matrix & inverseMat4()
nkMaths::Matrix::getInverseMat4
Matrix getInverseMat4() const
nkMaths::Matrix::setOrientationComponent
Matrix & setOrientationComponent(const Quaternion &rot)
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Matrix::transpose
Matrix & transpose()
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Matrix::getCol1
Vector getCol1() const
nkMaths::Matrix::setScaleComponent
Matrix & setScaleComponent(const Vector &scale)
nkMaths::Matrix::getCol0
Vector getCol0() const
nkMaths::Matrix::getTraceMat3
float getTraceMat3() const
nkMaths::Matrix::getRow3
Vector getRow3() const
nkMaths::Matrix::getRow2
Vector getRow2() const
nkMaths::Matrix::_m
float _m[4][4]
The matrix memory, considered in row-major order (_m[row][col]).
Definition: Matrix.h:483
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:15
nkMaths::Matrix::getScaleComponent
Vector getScaleComponent() const
nkMaths::Matrix::getCol3
Vector getCol3() const
nkMaths::Matrix::inverseMat3
Matrix & inverseMat3()
nkMaths::Matrix::getCol2
Vector getCol2() const
nkMaths::Matrix::setToOrthographicMatrix
Matrix & setToOrthographicMatrix(float widthNearPlane, float heightNearPlane, float near, float far)
nkMaths::Matrix::setToViewMatrixDirection
Matrix & setToViewMatrixDirection(const Vector &position, const Vector &direction, const Vector &upDirection)
nkMaths::Matrix::getDeterminantMat3
float getDeterminantMat3() const
nkMaths::Matrix::setPositionComponent
Matrix & setPositionComponent(const Vector &position)
nkMaths::Matrix::getDeterminantMat4
float getDeterminantMat4() const
nkMaths::Matrix::setToOffCenterPerspectiveMatrix
Matrix & setToOffCenterPerspectiveMatrix(float fovLeft, float fovRight, float fovTop, float fovBottom, float near, float far)
nkMaths::Matrix::getDeterminantMat2
float getDeterminantMat2() const
nkMaths::Matrix::getDecomposed
void getDecomposed(Vector &position, Matrix &orientation, Vector &scale) const
nkMaths::Matrix::setToTransformation
Matrix & setToTransformation(const Vector &position, const Quaternion &orientation, const Vector &scale)
nkMaths::Matrix::getRow0
Vector getRow0() const
nkMaths::Matrix::inverseMat2
Matrix & inverseMat2()
nkMaths::Matrix::getOrientationComponent
Matrix getOrientationComponent() const
nkMaths::Matrix::Matrix
Matrix() noexcept
nkMaths::Matrix::getRow1
Vector getRow1() const
nkMaths::Matrix::setToPerspectiveReverseZMatrix
Matrix & setToPerspectiveReverseZMatrix(float fov, float aspect, float near, float far=-1.f)
nkMaths::Matrix::setToOffCenterPerspectiveReverseZMatrix
Matrix & setToOffCenterPerspectiveReverseZMatrix(float fovLeft, float fovRight, float fovTop, float fovBottom, float near, float far=-1.f)
nkMaths::Matrix::setToOrthographicReverseZMatrix
Matrix & setToOrthographicReverseZMatrix(float widthNearPlane, float heightNearPlane, float near, float far)
nkMaths::Matrix::getPositionComponent
Vector getPositionComponent() const
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Matrix::setToPerspectiveMatrix
Matrix & setToPerspectiveMatrix(float fov, float aspect, float near, float far)
nkMaths::Matrix::get
float get(unsigned int row, unsigned int col) const
nkMaths::Matrix::getTranspose
Matrix getTranspose() const
nkMaths::Matrix::set
Matrix & set(float val, unsigned int row, unsigned int col)
nkMaths::Matrix::getInverseMat2
Matrix getInverseMat2() const
nkMemory
Encompasses all API of component NilkinsMemory.
Definition: Allocator.h:7